package com.example.main.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;
import com.example.main.controller.vo.ServiceVO;
import com.example.main.dao.ServicesMapper;
import com.example.main.entity.ServicesEntity;
import com.example.main.service.ServicesService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ServicesServiceImpl extends ServiceImpl<ServicesMapper, ServicesEntity> implements ServicesService {

    @Override
    public PageUtils queryPage(ServiceVO serviceVO) {
        QueryWrapper<ServicesEntity> wrapper = new QueryWrapper<>();

        if (StringUtils.isNoneBlank(serviceVO.getServiceName())) {
            wrapper.like("service_name", serviceVO.getServiceName());
        }

        Page<ServicesEntity> page = new Page<>(Integer.valueOf(serviceVO.getPage()), Integer.valueOf( serviceVO.getSize()));
        Page<ServicesEntity> ret = this.page(page, wrapper);
        return new PageUtils(ret);
    }
}
